package com.example.wxai.controller;



import com.example.wxai.pijo.dto.CommentDto;
import com.example.wxai.pijo.vo.CommentVo;
import com.example.wxai.result.PageResult;
import com.example.wxai.result.Result;
import com.example.wxai.service.ICommentService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-15
 */
@Slf4j
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Resource
    private ICommentService commentService;

    @PostMapping("/addComment")
    public Result<String> addComment(@RequestBody CommentDto commentDto){
        log.info("接收评论");
        commentService.addComment(commentDto);
        return Result.success();
    }


    @GetMapping("/getComment")
    public PageResult<CommentVo> getComment(String essayId,
                                            Integer pageNo, String userId){
        log.info("查看文章评论");
        PageResult<CommentVo> pageResult= commentService
                .getPageComment(essayId,pageNo,userId);
        return pageResult;
    }

}
